const USER_API = 'http://localhost:8080/api/users';

// 用户登录
async function login(user) {
    return fetch(`${USER_API}/login`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(user)
    }).then(res => res.json());
}

// 获取当前用户信息
async function getCurrentUser() {
    return fetch(`${USER_API}/current`, {
        headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
    }).then(res => res.json());
}